package sprites;

import java.awt.image.BufferedImage;
import java.io.File;
import java.io.IOException;

import javax.imageio.ImageIO;

public class TestSprite {
	private static final String imageFilePath = "resources/sprites/";
	
	// ----- folder: "bounce"
	
	private static BufferedImage BOUNCE_00;
	private static BufferedImage BOUNCE_01;
	private static BufferedImage BOUNCE_02;
	private static BufferedImage BOUNCE_03;
	private static BufferedImage BOUNCE_04;
	private static BufferedImage BOUNCE_05;
	private static BufferedImage BOUNCE_06;
	private static BufferedImage BOUNCE_07;
	private static BufferedImage BOUNCE_08;
	private static BufferedImage BOUNCE_09;
	
	
	
	// loading operation
	static{
		try{
			BOUNCE_00 = ImageIO.read(new File(imageFilePath+"animation01/bounce/anim_00.png"));
			BOUNCE_01 = ImageIO.read(new File(imageFilePath+"animation01/bounce/anim_01.png"));
			BOUNCE_02 = ImageIO.read(new File(imageFilePath+"animation01/bounce/anim_02.png"));
			BOUNCE_03 = ImageIO.read(new File(imageFilePath+"animation01/bounce/anim_03.png"));
			BOUNCE_04 = ImageIO.read(new File(imageFilePath+"animation01/bounce/anim_04.png"));
			BOUNCE_05 = ImageIO.read(new File(imageFilePath+"animation01/bounce/anim_05.png"));
			BOUNCE_06 = ImageIO.read(new File(imageFilePath+"animation01/bounce/anim_06.png"));
			BOUNCE_07 = ImageIO.read(new File(imageFilePath+"animation01/bounce/anim_07.png"));
			BOUNCE_08 = ImageIO.read(new File(imageFilePath+"animation01/bounce/anim_08.png"));
			BOUNCE_09 = ImageIO.read(new File(imageFilePath+"animation01/bounce/anim_09.png"));			
		}
		catch (IOException e) {
			throw new IllegalArgumentException(e + " -> Error loading images.");
		}
	}
	
	public static BufferedImage getFrame(SpriteModels model, int frame){
		switch (model) {
		case BOUNCE:
			return getBounce(frame);
		default:
			return null;
		}
	}
	
	private static BufferedImage getBounce(int frame){
		switch (frame) {
		case 0:
			return BOUNCE_00;
		case 1:
			return BOUNCE_01;
		case 2:
			return BOUNCE_02;
		case 3:
			return BOUNCE_03;
		case 4:
			return BOUNCE_04;
		case 5:
			return BOUNCE_05;
		case 6:
			return BOUNCE_06;
		case 7:
			return BOUNCE_07;
		case 8:
			return BOUNCE_08;
		case 9:
			return BOUNCE_09;
		default:
			return null;
		} 
	}
}
